function sortJson(obj) { 
  if (Array.isArray(obj)) {
    return obj.map(d => {
      return sortJson(d);
    })
  } else if (typeof obj === 'object'&& obj!= null) {
    let keys = Object.keys(obj);
    let o = {};
    keys.sort();
    keys.forEach(key => {
      if (Array.isArray(obj[key])) {
        o[key] = obj[key].map(d => {
          return sortJson(d);
        })
      } else if (typeof obj[key] === 'object') {
        o[key] = sortJson(obj[key]);
      } else {
        o[key] = obj[key];
      }
    });
    return o;
  } else {
    return obj;
  }
}

export{
  sortJson
}